﻿using Autofac;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.Compilation;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using Zj.HttpCodeDemo.App.Tag.EventHandlers;
using Zj.HttpCodeDemo.App.Tag.Events;
using Zj.HttpCodeDemo.Bus.Simple;
using Zj.HttpCodeDemo.Domain.Events;
using Zj.HttpCodeDemo.EventStore.Dapper;
using Zj.HttpCodeDemo.Integration;

namespace Zj.HttpCodeDemo.Mvc
{
    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            AutofacExt.Initialize();//Initialize autofac.
            var container = AutofacExt._builder.Build();
            var eventBus = container.Resolve<IEventBus>();
            eventBus.Subscribe<UserCreatedEvent,UserCreatedEventHandler>();
        }
    }
}
